package com.bf.electroplating.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bf.electroplating.mapper.WarningMapper;
import com.bf.electroplating.pojo.entity.Warning;
import com.bf.electroplating.service.IWarningService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 预警信息服务实现类
 * 
 * @author system
 * @since 2025-01-11
 */
@Service
public class WarningServiceImpl extends ServiceImpl<WarningMapper, Warning> implements IWarningService {

    @Override
    public List<Warning> getWarningsByModule(String module) {
        return list(new LambdaQueryWrapper<Warning>()
                .eq(Warning::getModule, module)
                .eq(Warning::getDelFlag, "0")
                .orderByDesc(Warning::getWarningTime));
    }

    @Override
    public List<Warning> getWarningsByCompanyId(String companyId) {
        return list(new LambdaQueryWrapper<Warning>()
                .eq(Warning::getCompanyId, companyId)
                .eq(Warning::getDelFlag, "0")
                .orderByDesc(Warning::getWarningTime));
    }

    @Override
    public List<Warning> getWarningsByLevel(String warningLevel) {
        return list(new LambdaQueryWrapper<Warning>()
                .eq(Warning::getWarningLevel, warningLevel)
                .eq(Warning::getDelFlag, "0")
                .orderByDesc(Warning::getWarningTime));
    }
}